//
//  XKProgressTimer.cpp
//  PlantNannyDemo
//
//  Created by Joueu on 14-10-22.
//
//

#include "XKProgressTimer.h"

XKProgressTimer::XKProgressTimer()
{
    
}
XKProgressTimer::~XKProgressTimer()
{
    
}

XKProgressTimer *XKProgressTimer::create(const char *timerName)
{
    XKProgressTimer *timer = new XKProgressTimer();
    if (timer && timer -> init(timerName)) {
        timer -> autorelease();
        return timer;
    }else{
        CC_SAFE_RELEASE(timer);
        return nullptr;
    }
}

XKProgressTimer *XKProgressTimer::createWithBG(const char *timerName, const char *bgName)
{
    XKProgressTimer *timer = new XKProgressTimer();
    if (timer && timer -> initWithBG(timerName,bgName)) {
        timer -> autorelease();
        return timer;
    }else{
        CC_SAFE_RELEASE(timer);
        return nullptr;
    }
}
bool XKProgressTimer::init(const char *timerName)
{
    if (!ProgressTimer::initWithSprite(Sprite::create(timerName))) {
        return false;
    }

    return true;
}
bool XKProgressTimer::initWithBG(const char *timerName, const char *bgName)
{
    if (!XKProgressTimer::initWithSprite((Sprite::create(timerName)))) {
        return false;
    }
    auto backGround = Sprite::create(bgName);
    this -> addChild(backGround);
    backGround -> setPosition(Point(this -> getContentSize().width *0.5,this -> getContentSize().height * 0.5));
    return true;
}